/* GUI CONVERTED from sqqorp03.p (converter v1.76) Wed Jul 10 23:13:59 2002 */
/* sqqorp03.p - LOST QUOTE REPORT                                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10 $                                                               */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 4.0     LAST MODIFIED: 12/12/88   BY: jms  *A548*                */
/*                                : 12/20/88   by: jms  *A566*                */
/*                                : 01/13/89   by: jms  *A604*                */
/* REVISION: 5.0     LAST MODIFIED: 03/17/89   by: RL   *B051*                */
/* REVISION: 6.0     LAST MODIFIED: 04/20/90   BY: ftb  *                     */
/* REVISION: 7.0     LAST MODIFIED: 03/27/92   BY: dld  *F326*                */
/* REVISION: 7.3     LAST MODIFIED: 04/10/96   BY: jzw  *G1P6*                */
/* REVISION: 7.3     LAST MODIFIED: 07/10/97   BY: *G2NX* Suresh Nayak        */
/* REVISION: 8.6     LAST MODIFIED: 10/06/97   BY: mzv *K0LL*                 */
/* REVISION: 8.6E    LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane           */
/* REVISION: 8.6E    LAST MODIFIED: 06/11/98   BY: *L02K* Russ Witt           */
/* REVISION: 9.1     LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane    */
/* REVISION: 9.1     LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown          */
/* REVISION: 9.1     LAST MODIFIED: 11/20/00   BY: *N0TW* Jean Miller         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.10 $    BY: Hareesh V             DATE: 06/21/02  ECO: *N1HY*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable lost            like qod_rsn_lost.
define variable lost1           like qod_rsn_lost.
define variable slspsn          as   character
                                label "Salesperson" format "x(8)".
define variable slspsn1         like slspsn.
define variable ord             like qo_ord_date.
define variable ord1            like qo_ord_date.
define variable name            like ad_name.
define variable cust            like qo_cust.
define variable cust1           like qo_cust.
define variable desc1           like rsn_desc.
define variable expdate         like qo_exp_date.
define variable expdate1        like qo_exp_date.
define variable site            like qo_site.
define variable site1           like qo_site.
define variable ext_price       like sod_price
                                label "Ext Price"
                                format "->,>>>,>>>,>>9.99".
define variable base_price      like qod_price.
define variable base_rpt        like so_curr.
define variable disp_curr       as   character format "x(1)" label "C".
define variable mc-error-number like msg_nbr   no-undo.

/* DATA DEFINITIONS FOR TRIANGULATION LIBRARY ROUTINES */
{gprunpdf.i "mcpl" "p"}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
lost    colon 20  lost1    label "To" colon 49
   cust    colon 20  cust1    label "To" colon 49
   slspsn  colon 20  slspsn1  label "To" colon 49
   ord     colon 20  ord1     label "To" colon 49
   expdate colon 20  expdate1 label "To" colon 49
   site    colon 20  site1    label "To" colon 49 skip(1)
   base_rpt colon 25
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if cust1 = hi_char
   then
      cust1 = "".

   if lost1 = hi_char
   then
      lost1 = "".

   if slspsn1 = hi_char
   then
      slspsn1 = "".

   if ord = low_date
   then
      ord = ?.

   if expdate = low_date
   then
      expdate = ?.

   if site1 = hi_char
   then
      site1 = "".

   if c-application-mode <> 'WEB'
   then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
             &fields  = "lost     lost1
                         cust     cust1
                         slspsn   slspsn1
                         ord      ord1
                         expdate  expdate1
                         site     site1
                         base_rpt"
             &frm = "a"}

   if     (c-application-mode <>     'WEB')
      or  (c-application-mode  =     'WEB'
      and (c-web-request      begins 'DATA'))
   then do:

      /* CREATE BATCH INPUT STRING */
      bcdparm = "".
      {mfquoter.i lost     }
      {mfquoter.i lost1    }
      {mfquoter.i cust     }
      {mfquoter.i cust1    }
      {mfquoter.i slspsn   }
      {mfquoter.i slspsn1  }
      {mfquoter.i ord      }
      {mfquoter.i ord1     }
      {mfquoter.i expdate  }
      {mfquoter.i expdate1 }
      {mfquoter.i site     }
      {mfquoter.i site1    }
      {mfquoter.i base_rpt }

      if cust1 = ""
      then
         cust1 = hi_char.

      if lost1 = ""
      then
         lost1 = hi_char.

      if slspsn1 = ""
      then
         slspsn1 = hi_char.

      if ord = ?
      then
         ord = low_date.

      if ord1 = ?
      then
         ord1 = today.

      if expdate = ?
      then
         expdate = low_date.

      if expdate1 = ?
      then
         expdate1 = today.

      if site1 = ""
      then
         site1 = hi_char.

      display
         expdate1
      with frame a.

   end. /* IF (c-application-mode <> 'WEB')... */

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:




   {mfphead.i}

   /* GET QUOTE DETAIL                                            */
   /* QUOTES WITH BLANK REASON CODE WILL BE PRINTED ONLY IF A     */
   /* BLANK REASON CODE IS DEFINED IN THE REASON CODE MAINTENANCE */
   /* FOR TYPE QUOTE                                              */

       {hksimsg.i site site1}       /*fdn*/

   for each rsn_ref
      fields (rsn_code rsn_desc rsn_type)
      where rsn_type  = "quote"
      and   rsn_code >= lost
      and   rsn_code <= lost1
      no-lock,
      each qod_det
         fields (qod_line      qod_nbr
                 qod_part      qod_price
                 qod_qty_quot  qod_rel_chg
                 qod_rsn_lost  qod_site
                 qod_um)
     where qod_rsn_lost  = rsn_code
         and   qod_rel_chg  <> 0
         and   qod_site     >= site and qod_site <= site1,
         each qo_mstr
            fields (qo_curr      qo_cust
                    qo_exp_date  qo_ex_rate
                    qo_ex_rate2  qo_nbr
                    qo_ord_date  qo_slspsn)
            where qo_nbr        = qod_nbr
            and   qo_cust      >= cust    and qo_cust      <= cust1
            and   qo_exp_date  >= expdate and qo_exp_date  <= expdate1
            and   qo_ord_date  >= ord     and qo_ord_date  <= ord1
            and ((qo_slspsn[1] >= slspsn  and qo_slspsn[1] <= slspsn1)
            or   (qo_slspsn[2] >= slspsn  and qo_slspsn[2] <= slspsn1)
            or   (qo_slspsn[3] >= slspsn  and qo_slspsn[3] <= slspsn1)
            or   (qo_slspsn[4] >= slspsn  and qo_slspsn[4] <= slspsn1))
            and  (base_rpt      = ""      or  base_rpt      = qo_curr)  AND LOOKUP(qo_site,GLOBAL_user_site) > 0    /*fdn*/
            no-lock
            break by qod_rsn_lost
                  by qod_part
                  by qo_cust
      with frame f-a width 132:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame f-a:handle).

      base_price = qod_price.
      disp_curr = "".
      if base_curr <> qo_curr
         and base_rpt = ""
      then do:

         /* CONVERT FROM FOREIGN TO BASE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input qo_curr,
              input base_curr,
              input qo_ex_rate,
              input qo_ex_rate2,
              input base_price,
              input false, /* DO NOT ROUND */
              output base_price,
              output mc-error-number)"}.
         disp_curr = getTermLabel("YES",1).
      end. /* IF base_curr <> qo_curr */

      assign
         ext_price = qod_rel_chg * base_price
         name = "".
      accumulate ext_price (total by qod_rsn_lost).

      for first ad_mstr
         fields (ad_addr ad_name)
     where ad_addr = qo_cust
      no-lock:
         name = ad_name.
      end. /* FOR FIRST ad_mstr */

      assign
         desc1 = ""
         desc1 = rsn_desc.

      if first-of(qod_rsn_lost)
      then do:
         if page-size - line-counter < 4
         then
            page.
         display WITH STREAM-IO /*GUI*/ .
         put
            {gplblfmt.i &FUNC=getTermLabel(""REASON_LOST"",15)
                        &CONCAT="': '"}
            qod_rsn_lost
            " "
            desc1
            skip(1).
      end. /* IF FIRST-OF(qod_rsn_lost) */

      if page-size - line-counter < 2
         and qo_slspsn[2]         > ""
      then
         page.
      else
         if page-size - line-counter <  3
            and qo_slspsn[3]         <> ""
         then
            page.
         else
            if page-size - line-counter  < 4
               and qo_slspsn[3]         <> ""
               and qo_slspsn[4]         <> ""
            then
               page.

      display
         qod_part
         qo_cust
         qod_nbr
         qod_line
         qod_qty_quot format "->>>>>>9.9<<<<"
         qod_rel_chg  format "->>>>>>9.9<<<<"
         qod_um
         disp_curr
         base_price
         ext_price
         qo_ord_date
         qo_exp_date
         qo_slspsn[1] WITH STREAM-IO /*GUI*/ .

      if qo_slspsn[2] > ""
      then do:
         down 1.
         display
            qo_slspsn[2] @ qo_slspsn[1] WITH STREAM-IO /*GUI*/ .
      end. /* IF qo_slspsn[2] > "" */

      if qo_slspsn[3] > ""
      then do:
         down 1.
         display
            qo_slspsn[3] @ qo_slspsn[1] WITH STREAM-IO /*GUI*/ .
      end. /* IF qo_slspsn[3] > "" */

      if qo_slspsn[4] > ""
      then do:
         down 1.
         display
            qo_slspsn[4] @ qo_slspsn[1] WITH STREAM-IO /*GUI*/ .
      end. /* IF qo_slspsn[4] > "" */

      if last-of(qod_rsn_lost)
      then do:
         underline  ext_price.
         display
            accum total by qod_rsn_lost ext_price @ ext_price WITH STREAM-IO /*GUI*/ .

         if last(qod_rsn_lost)
         then do:
            if page-size - line-counter < 3
            then
               page.
            underline ext_price.
            display
               accum total ext_price @ ext_price WITH STREAM-IO /*GUI*/ .
         end. /* IF LAST(qod_rsn_lost) */

      end. /* IF LAST-OF(qod_rsn_lost) */

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


   end. /* FOR EACH rsn_ref */

   /* REPORT TRAILER  */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end. /* REPEAT */

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" lost lost1 cust cust1 slspsn slspsn1 ord ord1 expdate expdate1 site site1 base_rpt "} /*Drive the Report*/
